﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using DHQGHN.DAL.DAO;
using DHQGHN.DAL.DAO.MappingDB;
using DHQGHN.DAL.DataMapper;
using DHQGHN.DAL.Models;
using DHQGHN.DAL.Models.MappingDB;

namespace DHQGHN.DAL.BO.MappingDB
{
    public class SD_ConfigDestinationBO : BaseBO
    {
        #region Field Name in return DataSet
        //Field Name in return DataSet
       public const string Field_ConfigDestinationID = "ConfigDestinationID";
        public const string Field_DataSource = "DataSource";
        public const string Field_ServerName = "ServerName";
        public const string Field_sUser = "sUser";
        public const string Field_sPassWord = "sPassWord";
        public const string Field_DataBaseName = "DataBaseName";  

        public const string Field_DS_IsActive = "IsActive";
        #endregion


        public String _connectionString;
        private SD_ConfigDestinationDAO _shareDAO;
        public SD_ConfigDestinationBO(string connString)
        {
            this._connectionString = connString;

        }
        public SD_ConfigDestinationBO()
        {
            this._connectionString = DEFAULT_CONN_STRING;

        }

        public SD_ConfigDestinationDAO CreateSQLDAO()
        {
            return new SD_ConfigDestinationDAO(_connectionString, DEFAULT_MAPPER_TYPE);
        }

        public SD_ConfigDestination Save(SD_ConfigDestination model)
        {
            try
            {
                _shareDAO = CreateSQLDAO();
                
                return _shareDAO.Save(model);
            }
            catch(Exception )
            {
                throw ;
            }
        }

        public SD_ConfigDestination GetLatestConfigSource()
        {
            try
            {
                _shareDAO = CreateSQLDAO();
                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {SD_ConfigDestination.Field_ConfigDestinationID,Field_ConfigDestinationID},
                    {SD_ConfigDestination.Field_DataBaseName,Field_DataBaseName},
                    {SD_ConfigDestination.Field_DataSource,Field_DataSource},                    
                    {SD_ConfigDestination.Field_ServerName,Field_ServerName},
                    {SD_ConfigDestination.Field_sPassWord,Field_sPassWord},
                    {SD_ConfigDestination.Field_sUser,Field_sUser},
                   
                    
                };
                return _shareDAO.GetSdConfigSource(mapDictionary);
            }
            catch (Exception)
            {
                throw;
            }
        }
       

    }
}
